package com.eclipse.org.snms.reminder;


import javax.swing.JPanel;
import java.awt.Dimension;
import javax.swing.JButton;
import java.awt.Rectangle;
import javax.swing.JLabel;
import javax.swing.JTextArea;
import javax.swing.JFrame;
import javax.swing.JScrollBar;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;

import com.eclipse.org.snms.StickyNote;


public class ReminderGUI extends JFrame {

	private JFrame jFrame = null;  //  @jve:decl-index=0:visual-constraint="161,47"
	private JPanel jContentPane2 = null;
	private JButton jButton1 = null;
	private JButton jButton2 = null;
	private JScrollBar jScrollBar = null;
	private JLabel jLabel = null;
	//private JTextArea jTextArea1 = null;
	private JTextArea jTextArea2 = null;
	private StickyNote stickyNote1;
	private boolean confirm = false;
	private boolean clicked = false;
	String showAlert;
	public ReminderGUI (String str) {
	//super(in, size);
		/*stickyNote1 = stickyNote;
		showAlert = "Stick Note Project " + stickyNote1.getId() + " \n" +
		((TaskComposite)stickyNote1).getTitle() + " gets expired now. \nIts description: " +
		stickyNote1.getDescription();*/
		
		//JFrame frame = this.getJFrame(); // create JFrame
		// close window
		showAlert = str;
		this.addWindowListener(new WindowAdapter() {
			public void windowClosing(WindowEvent e)
			{
				
				jTextArea2.setText(showAlert +"\n This StickyNote is snoozed");
				confirm = false;
				
				dispose();
				clicked = true;
			} 
		});
		
		
		setSize(430,294);
		setTitle("Reminder");
		setLocation(300,150);
        setResizable(false);
		
		
		this.getContentPane().add(getJContentPane2(str));
		show();
		//frame.pack();
		//frame.setVisible(true);


	}
	
		public boolean getConfirm() {
			return this.confirm;
		}
		
		public boolean getClicked() {
			return this.clicked;
		}
		
		
	/**
	 * This method initializes jFrame	
	 * 	
	 * @return javax.swing.JFrame	
	 */
	private JFrame getJFrame() {
		if (jFrame == null) {
			jFrame = new JFrame();
			jFrame.setSize(new Dimension(430, 294));
			//jFrame.setContentPane(getJContentPane2());
			
			jFrame.setTitle("Reminder");
		}
		return jFrame;
	}

	/**
	 * This method initializes jContentPane2	
	 * 	
	 * @return javax.swing.JPanel	
	 */
	private JPanel getJContentPane2(String str1) {
		if (jContentPane2 == null) {
			jLabel = new JLabel();
			jLabel.setBounds(new Rectangle(27, 13, 380, 18));
			jLabel.setText("You have following stick note, Stick Note Project, expired now!");
			jContentPane2 = new JPanel();
			jContentPane2.setLayout(null);
			jContentPane2.add(getJButton1(), null);
			jContentPane2.add(getJButton2(), null);
			jContentPane2.add(getJScrollBar(), null);
			jContentPane2.add(jLabel, null);
			
			jContentPane2.add(getJTextArea2(str1), null);
		}
		return jContentPane2;
	}

	/**
	 * This method initializes jButton1	
	 * 	
	 * @return javax.swing.JButton	
	 */
	private JButton getJButton1(){
		if (jButton1 == null) {
			jButton1 = new JButton();
			jButton1.setBounds(new Rectangle(86, 196, 80, 38));
			jButton1.setText("Confirm");
			jButton1.addActionListener(new Button1Handler());
		}
		return jButton1;
	}

	/**
	 * This method initializes jButton2	
	 * 	
	 * @return javax.swing.JButton	
	 */
	private JButton getJButton2() {
		if (jButton2 == null) {
			jButton2 = new JButton();
			jButton2.setBounds(new Rectangle(252, 196, 80, 38));
			jButton2.setText("Snooze");
			jButton2.addActionListener(new Button2Handler());

		}
		return jButton2;
	}
	
	private class Button1Handler implements ActionListener 
	{
		public void actionPerformed(ActionEvent e) 
		{
		  //jTextArea2.setText(showAlert +"\n This StickyNote is confirmed");
		  System.out.println(showAlert +"\n This StickyNote is confirmed");
		  confirm = true;
		  
		  dispose();
		  clicked = true;
		}
	}
	private class Button2Handler implements ActionListener
	{
		public void actionPerformed(ActionEvent e)
		{
		jTextArea2.setText(showAlert +"\n This StickyNote is snoozed");
		confirm = false;
		
		dispose();
		clicked = true;
		}
	}


	/**
	 * This method initializes jScrollBar	
	 * 	
	 * @return javax.swing.JScrollBar	
	 */
	private JScrollBar getJScrollBar() {
		if (jScrollBar == null) {
			jScrollBar = new JScrollBar();
			jScrollBar.setBounds(new Rectangle(375, 40, 17, 149));
			jScrollBar.addPropertyChangeListener(new java.beans.PropertyChangeListener() {
				public void propertyChange(java.beans.PropertyChangeEvent e) {
					if ((e.getPropertyName().equals("enabled"))) {
						System.out.println("propertyChange(enabled)"); // TODO Auto-generated property Event stub "enabled" 
					}
				}
			});
		}
		return jScrollBar;
	}

	
	/**
	 * This method initializes jTextArea2	
	 * 	
	 * @return javax.swing.JTextArea	
	 */
	public JTextArea getJTextArea2(String str) {
		if (jTextArea2 == null) {
			jTextArea2 = new JTextArea();
			jTextArea2.setBounds(new Rectangle(32, 40, 342, 147));
			
			jTextArea2.setText(str);
		}
		return jTextArea2;
	}

}  //  @jve:decl-index=0:visual-constraint="56,80"
